/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




function SearchData(){
    var SearchKeywords= document.formSearch.fSearchKeywords.value;
    var SearchCategory= document.formSearch.fSearchCategory.value;
    
    document.formExec.fSearchKeywords.value= SearchKeywords;
    document.formExec.fSearchCategory.value= SearchCategory;
    
    if(document.formSearch.fSearchKeywords.value == document.formSearch.fSearchKeywords.value && 
        document.formSearch.fSearchCategory.value == document.formExec.fSearchCategory.value){
        document.formExec.submit();     
    }
    else {
        alert("An error ocured. Please contfAct application vendor!");
        
    }

}

function ResetSearchData(){
    var SearchKeywords= "";
    var SearchCategory= "";
    
    document.formSearch.fSearchKeywords.value= SearchKeywords;
    document.formSearch.fSearchCategory.value= SearchCategory;
    document.formExec.fSearchKeywords.value= SearchKeywords;
    document.formExec.fSearchCategory.value= SearchCategory;
    
    if(document.formSearch.fSearchKeywords.value == document.formSearch.fSearchKeywords.value && 
        document.formSearch.fSearchCategory.value == document.formExec.fSearchCategory.value){
        document.formExec.submit();     
    }
    else {
        alert("An error ocured. Please contfAct application vendor!");
        
    }

}

function FirstPage(){
    document.formExec.fPage.value= 0;
    document.formExec.submit();
}

function PrevPage(){
    var CurPage= document.formExec.fPage.value;
    if(CurPage>0)
        CurPage--;
    
    document.formExec.fPage.value= CurPage;
    document.formExec.submit();
}

function GotoPage($pPage){
    var CurPage= document.formExec.fPage.value;
    
    document.formExec.fPage.value= $pPage;
    document.formExec.submit();
}

function NextPage(){   
    var CurPage= document.formExec.fPage.value;
    CurPage++;
    document.formExec.fPage.value= CurPage;
    document.formExec.submit();
}

function LastPage(pPage){
    document.formExec.fPage.value= pPage;
    document.formExec.submit();
}



$(document).ready(function() {
    $("#ActionButton-Container").click(
        function(){
            var action=  $(this).attr("class");
            
            if(action == "show") {
                $(".Action-Container").fadeIn("normal");
                $("#ActionButton-Container").removeClass("show");
                $("#ActionButton-Container").addClass("close");
            }
            else if(action == "close") {
                $(".Action-Container").fadeOut("normal");
                $("#ActionButton-Container").removeClass("close");
                $("#ActionButton-Container").addClass("show");
            }
        }
        );
    
    $(".Add-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
            
            if(tTarget) {
                document.formExec.fAct.value= "add";
                document.formExec.action= tTarget;
                document.formExec.submit();
            }
        }
        );   
            
    $(".Edit-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
       
            if(tTarget) {
                document.formExec.fAct.value= "edt";
                document.formExec.action= tTarget;
                document.formExec.submit();
            }
        }
        );   
            
    $(".Unlock-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
                
            if(tTarget) {
                document.formExec.fAct.value= "rst";
                document.formExec.action= tTarget;
                $("#dialog-ConfirmUnlock").dialog("open");
            }
        }
        );     
    $(".Reset-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
                
            if(tTarget) {
                document.formExec.fAct.value= "rst";
                document.formExec.action= tTarget;
                $("#dialog-ConfirmReset").dialog("open");
            }
        }
        );     
    $(".Detail-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
            
            if(tTarget) {
                document.formExec.fAct.value= "dtl";
                document.formExec.action= tTarget;
                $("#dialog-ConfirmOpenNewTab").dialog("open");
            }
        }
        ); 
        
        
    $(".Delete-Action").click( 
        function() {
            var tId= $(this).attr("rel");
            var tTarget= $(this).attr("href");
            document.formExec.fId.value= tId; 
                
            if(tTarget) {
                document.formExec.fAct.value= "del";
                document.formExec.action= tTarget;
                $("#dialog-ConfirmDelete").dialog("open");
            }
        }
        ); 
      
      
    $("#dialog-ConfirmOpenNewTab").dialog({
        autoOpen:false,
        resizable: false,
        width:350,
        height:125,
        modal: true,
        buttons: {
            "Yes": function() {
                $( this ).dialog( "close" );
                document.formExec.target='_blank';
                document.formExec.submit();
                document.formExec.target='_self';
            },
            "No": function() {
                $( this ).dialog( "close" );
                document.formExec.target='_self';
                document.formExec.submit();
            }
        }
    });
    
    $("#dialog-ConfirmDelete").dialog({
        autoOpen:false,
        resizable: false,
        width:350,
        height:125,
        modal: true,
        buttons: {
            "Ok": function() {
                $( this ).dialog( "close" );
                document.formExec.submit();
            },
            "Cancel": function() {
                document.formExec.fAct= "";
                $( this ).dialog( "close" );

            }
        }
    });
    
    $("#dialog-ConfirmUnlock").dialog({
        autoOpen:false,
        resizable: false,
        width:350,
        height:125,
        modal: true,
        buttons: {
            "Ok": function() {
                $( this ).dialog( "close" );
                document.formExec.submit();
            },
            "Cancel": function() {
                document.formExec.fAct= "";
                $( this ).dialog( "close" );

            }
        }
    });
    
    $("#dialog-ConfirmReset").dialog({
        autoOpen:false,
        resizable: false,
        width:350,
        height:125,
        modal: true,
        buttons: {
            "Ok": function() {
                $( this ).dialog( "close" );
                document.formExec.submit();
            },
            "Cancel": function() {
                document.formExec.fAct= "";
                $( this ).dialog( "close" );

            }
        }
    });
    
    
    
});